{	Problem: http://codeforces.ru/problemset/problem/80/A
	Verdict: Accepted
}
var i,j,a,b:longint; f,g:boolean;
begin
read(a,b);
f:=true;
for i:=a+1 to b do begin
  g:=true;
  for j:=2 to i-1 do
    if i mod j=0 then begin
      g:=false;
      break;
    end;
  if g and (i<>b) then begin
    f:=false;
    break;
  end;
  if (not g) and (i=b) then begin
    f:=false;
    break;
  end;
end;
if f then write('YES') else write('NO');
end.